/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.menosehmais.framework.util;

/**
 * Em fase de implementação...
 * 
 * @author Rafael Quintino
 * 
 * @see https://developer.palm.com/content/api/reference/javascript-libraries/foundations/foundations-string-utils.html
 * @see http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/smack/util/StringUtils.html
 * @see http://javaoltp.moredata.pt/javadoc/unstable/pt/moredata/util/StringUtils.html
 * @see http://gluemvc.sourceforge.net/api-current/org/griffante/glue/util/StringUtils.html
 * @see http://www.as3commons.org/as3-commons-lang/asdoc/org/as3commons/lang/StringUtils.html
 * @see http://commons.apache.org/lang/api-2.3/org/apache/commons/lang/StringUtils.html
 * @see http://code.google.com/p/opensutils-br4j/wiki/StringUtils
 * @see http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/util/StringUtils.html
 * 
 */
public class StringUtil {
    public static boolean isBlank(String string) {
        if( StringUtil.withoutWhitespace(string).isEmpty()){
            return true;
        }
        return false;
    }
    
     public static boolean isNotBlank(String string) {
         return !(StringUtil.isBlank(string));
     }
     
     public static boolean isNumeric(String string) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
     
     public static String withoutAccentuation(String string) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
     
     public static String withoutWhitespace(String string) {
         if(string != null) {
             StringBuilder stringBuilder = new StringBuilder();
             for(char character : string.trim().toCharArray()) {
                 if(!Character.isWhitespace(character)){
                     stringBuilder.append(character);
                 }
             }
             return stringBuilder.toString();
         }
         
         return "";
     }
     
     public static String toHexaString(byte[] bytes) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
            int parteAlta = ((bytes[i] >> 4) & 0xf) << 4;
            int parteBaixa = bytes[i] & 0xf;
            if (parteAlta == 0) s.append('0');
            s.append(Integer.toHexString(parteAlta | parteBaixa));
        }
        return s.toString();
    }
}
